
* Figure 3 - CSES (DON'T KNOW)

clear all	
cd "${data}"	
use "data1.dta", clear 


gen dk = .
replace dk = 0 if perception_dk_>=0 & perception_dk_<11
replace dk = 1 if perception_dk_==98
gen dk_daysafter = daysafter if dk ==1


eststo m_dk: mixed dk daysafter || country_: || election_: || respondent: , iterate(5)
margins, at(daysafter=(0(30)300)) post

marginsplot, ///
    title("") ///
    ytitle("predicted probability of don't know", size(3)) ///
    xtitle("days since election") ///
    xlabel(0(30)300, grid glpattern(solid) glcolor(gs14%50) glwidth(vthin)) ///
    ylabel(, grid glpattern(solid) glcolor(gs14%50) glwidth(vthin)) ///
    recast(scatter) ///
    recastci(rspike) ///
    addplot(hist dk_daysafter, percent color(gs12%30) yaxis(2) ///
        ytitle("percent", size(3) axis(2)) ///
        yscale(range(0(5)75) axis(2) alt)) ///
		plot1opts(lcolor(gs12) mcolor(gs12)) ///
    ciopts(lcolor(gs12) lwidth(thin)) ///
    legend(off) ///
    plotregion(lcolor(black) lwidth(thin) lpattern(solid))

* manually correct the ylabel .15 and .25
*ylabel(0 "0" 0.1 "10" 0.2 "20" 0.3 "30")
 graph save "${figures}/figure3.gph",  replace
 graph save "${figures}/figure3.png", replace
